package com.example.xui.BlankFragment;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.xui.R;


public class BlankFragment extends Fragment {
    BlankFragment3 f3=new BlankFragment3();
    private FragmentManager manager;
    private FragmentTransaction ft;
    private EditText editText;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_blank, container, false);
    }
    public void onActivityCreated(@Nullable Bundle saveInstanceState) {
        super.onActivityCreated(saveInstanceState);
        manager=getFragmentManager();
        editText=getActivity().findViewById(R.id.edit);
        Button button=getActivity().findViewById(R.id.button4);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle=new Bundle();
                bundle.putString("phone",editText.getText().toString());
                f3.setArguments(bundle);
                ft=manager.beginTransaction();
                ft.replace(R.id.framgement2,f3);
                ft.addToBackStack(null);
                ft.commit();
                ConstraintLayout constraintLayout=getActivity().findViewById(R.id.constraintlayout1);
                constraintLayout.setVisibility(View.INVISIBLE);
            }
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        Toast.makeText(getContext(),"onResour",Toast.LENGTH_SHORT).show();
        Log.i("BlankFragment.this","onResume");
        ConstraintLayout constraintLayout=getActivity().findViewById(R.id.constraintlayout1);
        ConstraintLayout constraintLayout1=getActivity().findViewById(R.id.constarintlayout2);
       // constraintLayout1.setVisibility(View.VISIBLE);
        if(constraintLayout.getVisibility()==View.INVISIBLE){
            constraintLayout1.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void onPause() {
        super.onPause();
      /*  ConstraintLayout constraintLayout1=getActivity().findViewById(R.id.constarintlayout2);
        constraintLayout1.setVisibility(View.VISIBLE);*/
   //     Toast.makeText(getContext(),"onPause0",Toast.LENGTH_SHORT).show();
      //  Log.i("BlankFragment.this","onPause1");
    }

    @Override
    public void onStop() {
        super.onStop();
       // Toast.makeText(getContext(),"onStop",Toast.LENGTH_SHORT).show();
   //     Log.i("BlankFragment.this","onStop2");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
     //   Log.i("BlankFragment.this","onDestroy2");
    }
}
